<template>
	<view class="goodsItem" @tap="toDetail">
		<image :src="goodsInfo.img" mode="widthFix"></image>
		<view class="goods ">
			<view class="info">
				<view class="name fs-28">
					{{goodsInfo.name}}
				</view>
				<view class="frenchName fs-24">
					{{goodsInfo.french}}
				</view>
				<view class="price fs-18">
					￥{{goodsInfo.price}}
				</view>
			</view>
			<view @tap.stop="addCart" class="addCart cuIcon-cart">
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"goods-item",
		data() {
			return {
				
			};
		},
		props: ['goodsInfo'],
		methods: {
			toDetail() {
				uni.navigateTo({
					url: "/subPackages/detail/detail?goodsDetail=" + JSON.stringify(this.goodsInfo)
				})
			},
			addCart() {
				let cartItem = {
					goodsDetail: this.goodsInfo,
					currentIndex: 0,
					count: 1,
					ischecked: false
				}
				uni.setStorage({
					key: "cart",
					data: cartItem
				})
				const a = uni.getStorageSync('cart')
				
				console.log('cartItem', a)
				this.$store.commit('ADD_CART_LIST', cartItem)
			}
		}
	}
</script>

<style lang="scss">
	.goodsItem{
		width: 350upx;
		padding: 10upx;
		image{
			width: 100%;
		}
		.goods{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 5upx;
			.info{
				.name{
					margin-top: 5upx;
				}
				.frenchName{
					margin: 5upx 0;
				}
			}
			.addCart{
				background-color: #f9e45c;
				width: 50upx;
				height: 50upx;
				border-radius: 50%;
				text-align: center;
				line-height: 50upx;
			}
		}
		
	}
</style>
